//graham matuszewski
#pragma once

#ifndef GANTRYTEST_H_
#define GANTRYTEST_H_

#include <iostream>
#include "Enums.h"
#include "Structs.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "Agent.h"
#include "GantryAgentMock.h"
#include "GUIFeederMock.h"
#include "FeederAgent.h"
#include "Feeder.h"
#include "FeederAgentMock.h"
#include <string>
//test of the feeder
	void sleep(unsigned int mseconds)
	{
		clock_t goal = mseconds + clock();
		while (goal > clock());
	}
class GantryTest : public ::testing::Test {
public:
	GantryTest() : gantry("Gantry Test"){

	}
	//virtual ~TestKittingCell(){delete &feeder;}
	GantryAgent gantry;
	FeederAgentMock feederMock1;
	FeederAgentMock feederMock2;
	FeederAgentMock feederMock3;
	FeederAgentMock feederMock4;
	//GUIFeederMock guiFeederMock;

//	int PullInMyLibrary() { return 0; }
	virtual void SetUp() {
		//feeder.setGantry(&gantryMock);
		//feeder.setLaneBottom(&bottomLaneMock);
		//feeder.setLaneTop(&topLaneMock);
		gantry.setFeeder1(&feederMock1);
		gantry.setFeeder2(&feederMock2);
		gantry.setFeeder3(&feederMock3);
		gantry.setFeeder4(&feederMock4);

	}

	Feeder* getFeeder1(){
		return gantry.getFeeder1();
	}
	Feeder* getFeeder2(){
		return gantry.getFeeder2();
	}
	Feeder* getFeeder3(){
		return gantry.getFeeder3();
	}
	Feeder* getFeeder4(){
		return gantry.getFeeder4();
	}

	void print(std::string text){
		std::cout << "Gantry " << ": " << text << std::endl;
	}
	void runScheduler(){
		gantry.pickAndExecuteAnAction();
	}
	
};

TEST_F(GantryTest, InitialTests){
	try{
	//EXPECT_FALSE(isGuiStarted());
	
	//EXPECT_FALSE(isFeederMoving());
	//EXPECT_FALSE(isPurgeHappening());
	//EXPECT_TRUE(true);
	//std::cout<<"IS THIS SHIT WORKING";
	//std::getchar();
		print("Gantry created successfully");
	}
	catch(std::exception &e){
		std::cout<<"Gantry not successful";
		//std::getchar();

	}
	
}

TEST_F(GantryTest, setFeeders){

	EXPECT_EQ(&feederMock1,getFeeder1());
	EXPECT_EQ(&feederMock2,getFeeder2());
	EXPECT_EQ(&feederMock3,getFeeder3());
	EXPECT_EQ(&feederMock4,getFeeder4());
}
TEST_F(GantryTest, firstMessage){

	PartRecipe partRec;
	partRec.partType=A;
	partRec.topLane=false;
	gantry.msgPleaseGetParts(partRec,&feederMock1);
	//EXPECT_EQ(1,getNewRecipeSize());
	//EXPECT_EQ(0,getTopRecipeNumber());
	//PartRecipe temp = getTopRecipe()->partRecipe;
	//EXPECT_EQ(partRec, temp );
	//gantryMock.msgPleaseGetParts(tempRecipe,&feeder);
	//fee.pickAndExecuteAnAction();
	//EXPECT_TRUE(runScheduler());
	

}
TEST_F(GantryTest, twoMessages){
	PartRecipe partRec;
	partRec.partType=A;
	partRec.topLane=false;
	gantry.msgPleaseGetParts(partRec,&feederMock1);
	EXPECT_CALL(feederMock1,msgCurrentStatus());
	runScheduler();
	gantry.msgFeederStatus(&feederMock1,false);
	sleep(6000);
	//runScheduler();
	//runScheduler();
	//EXPECT_CALL(feederMock1,msgHereAreParts(partRec));
	//gantry.msgGUIHalfDoneMoving(FeederOrder(partRec,0));


}



TEST_F(GantryTest, justForDebugs){
	//std::getchar();
	//why you not working
}


#endif